﻿function GetTotalPages(grid, dataTable) {
    var pageSize = grid.jqGrid("getGridParam", "rowNum");

    var remainder = dataTable.length % pageSize;
    var totalPages = (dataTable.length - remainder) / pageSize;

    if (remainder > 0) {
        totalPages++;
    }

    return totalPages;
}


function BindGrid(grid, dataTable, dataKeyName, pageNumber) {
    // clear any data currently in the grid
    grid.jqGrid("clearGridData");

//    var pageSize = grid.jqGrid("getGridParam", "rowNum");
//    var totalPages = GetTotalPages(grid, dataTable);

//    // if page number is not specified then just reload the current page
//    if (!pageNumber) {
//        pageNumber = grid.data("CurrentPage");
//    }

//    // make sure the page number is within bounds
//    if (pageNumber < 1) { pageNumber = 1; }
//    if (pageNumber > totalPages) { pageNumber = totalPages; }

//    // get the subset of data for the specified page
//    var startRowIndex = (((pageNumber - 1) * pageSize) + 1) - 1;
//    //var pageData = dataTable.slice(startRowIndex, startRowIndex + pageSize);
    var pageData = dataTable;

    grid.jqGrid("addRowData", dataKeyName, pageData);

    grid.jqGrid().trigger("reloadGrid");
}


function clock() {
    var d = new Date();
    var t = d.toLocaleTimeString();
    document.getElementById("clock").value = t;
}

